﻿<html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
            企业进销存系统
        </title>
        <link rel="stylesheet" href="./css/common.css" type="text/css" media="screen"/>
        <script type="text/javascript" src="./js/jquery-1.8.3.min.js"></script> 
    </head>
    
    <body id="taa">

        <div id="headsy">
            <lable>搜索:</lable>
            <select>
                <option>苏宁店</option>
                <option>龙哥店</option>
            </select>
            <div class='button' onclick='clickLog();'>查询</div>
        </div>
        <div class="tableremain">
            <table>
                <tr>
                    <td style="width:100px">产品编号</td>
                    <td style="width:200px">产品名称</td>
                    <td style="width:100px">规格</td>
                    <td style="width:100px">状态</td>
                    <td style="width:100px">单价</td>
                    <td style="width:100px">库存数量</td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                
            </table>
        </div>
        
    </body>
    <script>
        
        $(document).ready(function(){
            $.ajax({
                type : "POST",
                url : "/jxc/firststocksearch.do",
                async:false,
                data:{},
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType : 'json',
                success : function(data) {
                    //alert(data.result);
                    if(data.shop=="[]"){
                        
                    }else{
                        aaa="";
                        aaa+='<div id="headsy"><lable>搜索:</lable><select id="type">';
                        $.each(data.shop, function(index, shopjson) {
                            aaa+='<option>'+shopjson.name+'</option>';
                        });
                        aaa+='</select><div class="button"  onclick="clickLog();">查询</div></div>';
                        aaa+='<div class="tableremain" id="xixi1"><table><tr><td style="width:100px">产品编号</td><td style="width:200px">产品名称</td><td style="width:100px">规格</td><td style="width:100px">状态</td><td style="width:100px">单价</td><td style="width:100px">库存数量</td></tr>';
                        $.each(data.result, function(index, productjson) {
                                aaa+='<tr><td>'+productjson.productid+'</td><td>'+productjson.productname+'</td><td>'+productjson.style+'</td><td>'+productjson.state+'</td><td>'+productjson.price+'</td><td>'+productjson.num+'</td></tr>';
                            });
                            aaa+='</table></div>';
                        $("#taa").html(aaa);
                    }
                    $('.tableremain td').attr('class','tabletd');
                    
                },
                error : function(data) {
                   alert("error");
                }                  
            });
        });
    </script>
    <script>
        function clickLog(){
            $.ajax({
                type : "POST",
                url : "/jxc/stocksearch.do",
                async:false,
                data:{"name":$('#type').val()},
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType : 'json',
                success : function(data) {
                    //alert(data.result);
                    if(data.shop=="[]"){
                        
                    }else{
                        aaa="";
                        aaa+='<table><tr><td style="width:100px">产品编号</td><td style="width:200px">产品名称</td><td style="width:100px">规格</td><td style="width:100px">状态</td><td style="width:100px">单价</td><td style="width:100px">库存数量</td></tr>';
                        $.each(data.result, function(index, productjson) {
                        aaa+='<tr><td>'+productjson.productid+'</td><td>'+productjson.productname+'</td><td>'+productjson.style+'</td><td>'+productjson.state+'</td><td>'+productjson.price+'</td><td>'+productjson.num+'</td></tr>';
                        });
                        aaa+='</table>';
                        $("#xixi1").html(aaa);
                    }
                    $('.tableremain td').attr('class','tabletd');
                    
                },
                error : function(data) {
                   alert("error");
                }                  
            });
        }
    </script>

</html>